package com.lee.lee.AiController;

import org.springframework.ai.chat.ChatClient;
import org.springframework.ai.chat.messages.UserMessage;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * ClassName: TestController
 * Package: com.lee.lee.AiController
 * Description:
 *
 * @Author 梓维李
 * @Create 2024/7/28 23:20
 * @Version 2.0
 */
@Controller
@RequestMapping("/v1")
public class TestController {

    @Autowired
    private ChatClient chatClient ;

    @RequestMapping("test01")
    @ResponseBody
    public String test01(String msg){
        //String msg = "最近有什么开心事情" ;
        Prompt prompt = new Prompt(new UserMessage(msg));
        String content = chatClient.call(prompt).getResult().getOutput().getContent();
        System.out.println(content);
        return content ;
    }
}
